<template>
  <span>
    <slot v-if="initSuccess"></slot>
  </span>
</template>

<script>
/**
 * Delay component
 *
 * use demo:
 *  <delay :timeout="3">.........</delay>
 *
 */
export default {
  name: 'DelayComponent',
  props: {
    timeout: {
      type: Number,
      default: 0
    }
  },
  data() {
    return {
      initSuccess: false
    }
  },
  methods: {
    init() {
      const timeout = this.timeout > 0 ? this.timeout * 1000 : 1
      // const timeout = this.timeout > 0 ? this.timeout : 1
      setTimeout(() => {
        this.initSuccess = true
      }, timeout)
    }
  },
  created() {
    this.init()
  }
}
</script>
